# coding=utf-8
from script import data

__author__ = 'awh'

import web

urls=(
    '','Upload'
)

class Upload(object):
    def GET(self):
        web.header("Content-Type","text/html; charset=utf-8")
        return """<html><head></head><body>
<form method="POST" enctype="multipart/form-data" action="">
<input type="file" name="myfile" />
<br/>
<input type="submit" />
</form>
</body></html>"""

    def POST(self):
        x = web.input(myfile={})
        a= x['myfile'].filename.decode('utf-8')
        b= x['myfile'].value
        c= x['myfile'].file.read()
        n= data.novel(name=a,cont=b)
        n.put()

app=web.application(urls,locals())